//
//  LGTBageView.swift
//  KJLGT
//
//  Created by jenkin on 2019/9/24.
//  Copyright © 2019年 jenkin. All rights reserved.
//

import UIKit

class LGTBageView: UIView {
    //label
    private var bageLabel:UILabel?
    private var _bageValue:String?
    var bageValue:String?{
        set{
            _bageValue = newValue
            self.setUI()
        }
        get{
            return _bageValue
        }
    }
    
    func setUI(){
        if self.bageValue == nil{
            self.isHidden = true
            return
        }
        
        self.isHidden = false
        self.bageLabel?.text = self.bageValue ?? "1"
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        self.backgroundColor = UIColor.red
        self.layer.masksToBounds = true
        self.layer.cornerRadius = SizeFitFloat(10)
        
        self.bageLabel = LGTViewCreateUtil.share.createLabel(textAlignment: NSTextAlignment.center, textColor: UIColor.white, fontSize: SizeFitFloat(12), text: "")
        self.addSubview(self.bageLabel!)
        self.bageLabel?.adjustsFontSizeToFitWidth = true
        self.addSubview(self.bageLabel!)
        self.bageLabel?.snp.makeConstraints({ (make) in
            make.center.equalTo(self)
            //make.width.equalTo(SizeFitFloat(15))
            //make.height.equalTo(SizeFit(15))
            make.width.equalTo(SizeFitFloat(20))
        })
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
